var snd = function() {
	/* private */ var snd_clip=null;
	/* private */ var snd__tmp_clip=null;
	/* private */ var snd__monitorSound=options.getValue("TVTID.Sound.Filename");
	/* private */ var snd__useSound=!!parseInt(options.getValue("TVTID.Sound.Active"));

	/* private */ var snd__initialized=false;
	/* private */ var snd__validExtensions={
		wav:true,
		wma:true,
		mp3:true
	};
	/* private */ var snd__object = null;

	/* private */ function snd__hover () {
		snd__object._dragZone.background = "images/backgrounds/ddbg_o.png";
	}
	/* private */ function snd__standard () {
		snd__object._dragZone.background = "images/backgrounds/ddbg_u.png";
	}
	/* private */ function snd__deny () {
		snd__object._dragZone.background = "images/backgrounds/ddbg_no.png";
	}
	/* private */ function snd__label (file) {
		snd__object._label.innerText = "Media: " + file.substring(file.lastIndexOf(framework.runtime.osName.match("windows") ? "\\" : "/") + 1);
	}
	/* private */ function snd__validateFile (obj) {
		if (!obj) {
			return false;
		}
		var e = new Enumerator(obj);
		var path = e.item();

		if (snd__validExtensions[path.substring(path.lastIndexOf(".") + 1).toLowerCase()] != true) {
			return false;
		}
		return path;
	}

	/* prot. subclass */ function _Sound() {
		this._dragZone= typeof xml_monitorMediaDropzone != "undefined" ? xml_monitorMediaDropzone : null;
		this._label =	typeof xml_dropzoneLabel != "undefined" ? xml_dropzoneLabel : null;
		snd__useSound =	typeof xml_dropzoneLabel != "undefined" ? true : !!options.getValue("TVTID.Sound.Active");
	}
	/* subclass var */_Sound.prototype._dragZone = null;
	/* subclass var */_Sound.prototype._label = null;

	/* subclass method */_Sound.prototype.load = 
	function (file) {
		if(snd__useSound) {
			if(file) snd__monitorSound = file;
			snd__clip = framework.audio.open(snd__monitorSound);
		}
	}
	/* subclass method */_Sound.prototype.play = 
	function snd__play() {
	if(vverbose)log(__FUNCTION())
		this.stop();
		if (this._clip != null) {
	if(vverbose)log(__FUNCTION())
			this._clip.play();
		}
	}
	/* subclass method */_Sound.prototype.stop = 
	function () {
		if (this._clip != null) {
			this._clip.stop();
		}
		if (snd__tmp_clip != null) {
			snd__tmp_clip.stop();
		}
	}
	/* subclass method */_Sound.prototype.saveSoundSettings = 
	function () {
		options.putValue("TVTID.Sound.Filename", xml_monitorMediaFile.value);
		options.putValue("TVTID.Sound.Active", xml_monitorUseSound.value == true ? 1 : 0);
	}

	/* subclass method */_Sound.prototype.teaser = 
	function (file) {
		if (snd__tmp_clip != null) {
			snd__tmp_clip.stop();
		}
		if (typeof file != "undefined" && file != null) {
			snd__tmp_clip = framework.audio.open(file);
		}
		if(snd__tmp_clip != null) {
			snd__tmp_clip.play();
			setTimeout(function () {
				snd__tmp_clip.stop();
			}, 8000);
		}
	};
	/* subclass method */_Sound.prototype.onDragDrop = 
	function () {
		var file = snd__validateFile(event.dragFiles);
		if (file == false) {
			snd__standard();
			return;
		}
		this.load(file);
		xml_monitorMediaFile.value = file;
		snd__standard();
	}
	/* subclass method */_Sound.prototype.onDragOver = 
	function () {
		snd__hover();
		var file = snd__validateFile(event.dragFiles);
		if (file == false) {
			var self = this;
			setTimeout(snd__deny, 450);
			event.returnValue = false;
			return;
		}
		snd__label(file);
		this.teaser(file);
	}
	/* subclass method */_Sound.prototype.onDragOut = 
	function () {
		snd__standard();
		snd__label(snd__monitorSound);
	};


	/* public */
	return {

		getInstance : function() {
			if(snd__object == null) {
				snd__object = new _Sound();
				if(snd__monitorSound == "") {
					snd__monitorSound = gadget.storage.extract("snd/inc.mp3");
				}
				snd__object.load(snd__monitorSound);
			}
			return snd__object;
		}
	}
}();
var Sound = snd.getInstance();
/*
function showMonitorEvent() {
	Favourites.getInstance().showMonitor();
}
*/
